namespace :beansrock do

	desc 'Define Admin'
	require 'site_config.rb'
	task :define_admin => :environment do

		begin
			login = ADMIN_LOGIN
			email = ADMIN_EMAIL
			password = ADMIN_PASSWORD
		rescue
			error = true
			result_message = "configure required.\n1) cp config/site_config.rb.example config/site_config.rb\n2) edit site_config.rb with your favorite editor."
		end

		if error.blank?
			admin = User.new(
				:login => login,
				:email => email,
				:role => 1,
				:password => password,
				:password_confirmation => password
			)


			if admin.save
				result_message = "Account \"#{login}\" has created successfully."
			else
				result_message = "Error Occured.\n#{admin.errors.full_messages.to_sentence}"
			end
		end

		puts ""
		puts result_message
		puts ""

	end
end
